package com.yl.nettylearning.netty.day03;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @author yangl
 */
public class HttpServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        //向管道中加入处理器

        //的到管道
        ChannelPipeline pipeline = ch.pipeline();
        //加入一个netty提供的httpServerCodec codec => [coder - decoder]
        //HttpServerCodec 是netty提供的一个http编解码器
        pipeline.addLast("HttpServerCodec", new HttpServerCodec());
        //增加一个自定义的处理器
        pipeline.addLast("HttpServerHandler", new HttpServerHandler());
    }
}
